package com.force.abril.prevision.download;

import java.util.List;



import org.dom4j.tree.ElementNameIterator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import br.com.abril.prevision.Prevision;
import br.com.abril.prevision.PrevisionService;

import com.force.abril.api.QueryResult;
import com.force.abril.api.SObject;
import com.force.api.connector.SalesForceQueryService;

@Service
public class PrevisionServiceActivator implements PrevisionSelector {

	@Autowired
	private SalesForceQueryService selector;
	
	@Autowired
	private PrevisionService service;
	
	@Autowired
	private PrevisionTransformer tranformer;
	
    public PrevisionServiceActivator() {
    }

    @Transactional
    public void downloadPrevisions () {
    	long start = System.currentTimeMillis();
    	QueryResult result = selector.searchFor(SELECT);
    	long end = System.currentTimeMillis();
    	
    	System.out.println(result);
    	System.out.println("Time sec " + (end - start) / 1000 );
    	
    	List<SObject> values = result.getRecords();
    	
    	SObject val = values.get(0);
    	List<Object> row = val.getAny(); 
    	Object column = row.get(0);

    	
    }

    
    
    
    
}
